@{ViewBag.Title = "Paging";}
@section CssImport{<link href="@Url.Content("~/Scripts/validationEngine/validationEngine.jquery.css")" rel="stylesheet" type="text/css" />}
@section JavascriptImport{
<script type="text/javascript" src="@Url.Content("~/Scripts/validationEngine/jquery.validationEngine.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/validationEngine/jquery.validationEngine-en.js")"></script>}
<div class="filtering"><form>
<label>Introduzca texto para filtrar: <input type="text" name="filter" id="filter" /></label>
<button type="submit" id="LoadRecordsButton" class="button medium orange" >Buscar Coincidencias</button>
</form></div>
<div id="MyTableContainer"></div>
<script type="text/javascript">
     $(document).ready(function () {
     $('#MyTableContainer').jtable({
         title: 'HD_NivelJerarquico',
         paging: true,
         pageSize: 10,
         sorting: true,
         defaultSorting: 'Id ASC',
         actions: {
             listAction: '@Url.Action("JSONPagedListByFilter")',
             deleteAction: '@Url.Action("JSONDelete")',
             updateAction: '@Url.Action("JSONUpdate")',
             createAction: '@Url.Action("JSONCreate")'
         },
         fields:
         {
          Id: {
                 key: true,
                 create: false,
                 edit: false,
                 list: false
             }
             ,
             Guid: {
                 type:'hidden'
             }          
             
             ,
             Codigo: {
                 title:'Codigo',
                 create: true,
                 edit: true,
                 list: true,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             Nombre: {
                 title:'Nombre',
                 create: true,
                 edit: true,
                 list: true,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             Descripcion: {
                 title:'Descripcion',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false,
                 type: 'textarea'
             }
             ,
             PrioridadTecnicaId_FK:{
                 title : 'HD_PrioridadTecnica',
                 create : true,
                 edit : true,
                 list : true,
                 options : '@Url.Action("../HD_PrioridadTecnica/JSONGetElementsForDropDownList")'
             },


             Phones: {
                 title: 'Items',
                 width: '10%',
                 sorting: false,
                 edit: false,
                 create: false,
                 listClass: 'child-opener-image-column',
                 display: function (studentData) {
                     var $img = $('<img class="child-opener-image" with="15" height="15" src="../../Content/images/comment.png" title="Click para ver items" />');
                     //Open child table when user clicks the image
                     $img.click(function () {
                         $('#MyTableContainer').jtable('openChildTable',
                                    $img.closest('tr'),
                                    {
                                        title: 'Items del Nivel Jerarquico',
                                        actions: {
                                            listAction: '@Url.Action("../HD_NivelJerarquicoItem/JSONItemsPorNivelJerarquico")?NivelJerarquicoId=' + studentData.record.Id,
                                            deleteAction: '@Url.Action("../HD_NivelJerarquicoItem/JSONDelete")',
                                            updateAction: '@Url.Action("../HD_NivelJerarquicoItem/JSONUpdate")',
                                            createAction: '@Url.Action("../HD_NivelJerarquicoItem/JSONCreate")'
                                        },
                                        fields: {
                                            NivelJerarquicoId_FK: {
                                                type: 'hidden',
                                                defaultValue: studentData.record.Id
                                            },
                                            Id: {
                                                key: true,
                                                create: false,
                                                edit: false,
                                                list: false
                                            }
                                            ,
                                            BOA_NivelJerarquicoId: {
                                                title: 'BOANivelJerarquico',
                                                create: true,
                                                edit: true,
                                                list: true,
                                                options: '@Url.Action("JSONListaJerarquiaBOA")'
                                            }                                            
                                           

                                        }
                                    }, function (data) { //opened handler
                                        data.childTable.jtable('load');
                                    });
                     });
                     //Return image to show on the person row
                     return $img;
                 }
             }










},
formCreated: function (event, data) {data.form.validationEngine();},
formSubmitting: function (event, data) {return data.form.validationEngine('validate');},
formClosed: function (event, data) { data.form.validationEngine('hide'); data.form.validationEngine('detach'); }
});
$('#LoadRecordsButton').click(function (e) {e.preventDefault();$('#MyTableContainer').jtable('load', {filter: $('#filter').val()});});
$('#LoadRecordsButton').click();
});
</script>

